home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / µSim 1.0.5 / FabLibsƒ / FabACursors.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  1.2 KB  |  67 lines  |  [TEXT/CWIE]

  1. #include    "FabWmemman.h"
  2. #include    "FabACursors.h"
  3.  
  4. struct fcur {
  5.     short    firstFrameID;
  6.     short    lastFrameID;
  7.     };
  8.  
  9. typedef struct fcur fcur, *fcurPtr, **fcurHandle;
  10.  
  11. static CursHandle *gCursors = nil;
  12. static short    gHowMany = 0;
  13.  
  14. OSErr FabLoadCursors(short fCurResID)
  15. {
  16. fcurHandle    cResH;
  17. CursHandle    tempC;
  18. short    first, last, i;
  19. OSErr    err;
  20.  
  21. cResH = (fcurHandle)Get1Resource('fCur', fCurResID);
  22. if (cResH) {
  23.     first = (*cResH)->firstFrameID;
  24.     last = (*cResH)->lastFrameID;
  25.     gHowMany = last - first;
  26.     gCursors = fmalloc((gHowMany + 1) * sizeof(CursHandle));
  27.     for (i = first; i <= last; i++) {
  28. //    for (i = 0; i <= gHowMany; i++) {
  29.         tempC = GetCursor(i);
  30. //        tempC = GetCursor(i + first);
  31.         if (tempC == nil) {
  32.             FabFreeCursors();
  33.             break;
  34.             }
  35.         gCursors[i - first] = tempC;
  36. //        gCursors[i] = tempC;
  37.         }
  38.     }
  39. else
  40.     err = ResError();
  41. return err;
  42. }
  43.  
  44. void FabRotateCursor(void)
  45. {
  46. static UInt32    oldtick = 0;
  47. static int    indx = 0;
  48. UInt32 tick = TickCount();
  49.  
  50. if ((tick - oldtick) > 40UL /*&& LMGetCrsrBusy() == false*/) {
  51.     indx++;
  52.     indx &= gHowMany;
  53.     SetCursor(*gCursors[indx]);
  54.     oldtick = tick;
  55.     }
  56. }
  57.  
  58. void FabFreeCursors(void)
  59. {
  60. if (gCursors) {
  61.     ffree(gCursors);
  62.     gCursors = nil;
  63.     gHowMany = 0;
  64.     }
  65. }
  66.  
  67.